package com.woniu.stafforder.controller;

import com.woniu.common.dto.OrderDetailDto;
import com.woniu.common.util.ResponseData;
import com.woniu.stafforder.dto.ChangeChildrenOrderStateDto;
import com.woniu.stafforder.service.OrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * 子订单
 */
@RestController
public class OrderDetailController {
    @Autowired
    private OrderDetailService orderDetailService;

    /**
     * 根据子订单id查询子订单
     * @param id
     * @return
     */
    @GetMapping("/queryOrderDetailById")
    public OrderDetailDto queryOrderDetailById(Long id) {
        return orderDetailService.queryOrderDetailById(id);
    }

    /**
     * 批量修改子订单状态
     * @param changeChildrenOrderStateDto
     * @return
     */
    @PostMapping("/updateChildrenOrderStatus")
    public Boolean updateChildrenOrderStatus(@RequestBody ChangeChildrenOrderStateDto changeChildrenOrderStateDto) {
        return orderDetailService.updateChildrenOrderStatus(changeChildrenOrderStateDto);
    }

    /**
     * 根据子订单id查信息
     * @param orderNum
     * @return
     */
    @GetMapping("/queryPageDetail/{orderNum}")
    public ResponseData<?> queryPageDetail(@PathVariable("orderNum") Long orderNum) {
        return orderDetailService.queryPageDetail(orderNum);
    }

    /**
     * 根据子订单id查询主订单id
     * @param id
     * @return
     */
    @GetMapping("/queryMainOrderNumByChildId")
    public Long queryMainOrderNumByChildId(Long id) {
        return orderDetailService.queryMainOrderNumByChildId(id);
    }

    @GetMapping("/queryTotalPayMoneyByIdList")
    public BigDecimal queryTotalPayMoneyById(List<Long> idList) {
        return orderDetailService.queryTotalPayMoneyById(idList);
    }
}